
#include "StdAfx.h"
#include "StateService.h"
#include "StateLoader.h"
#include "StateSet.h"

StateService::StateService(){
	loader_ = new StateLoader();
}

StateService::~StateService(){
	SAFE_DELETE( loader_ );
}

//err test
//////////////////////////////////////////////////////////////////////////
int StateService::initialize_dummy( char* file_name ){
	if( loader_->dummy_load( file_name ) )
		return DEFAULT_SUCCESS;
	
	return DEFAULT_SUCCESS;
}
//////////////////////////////////////////////////////////////////////////

int StateService::initialize( char* file_name ){
	if( loader_->load( file_name ) )
		return DEFAULT_SUCCESS;

	return DEFAULT_SUCCESS;
}

StateSet* StateService::register_stateset( char* name ){
	StateSet* value = states_.get( name );
	if( value )
		return value;

	StateSet* set = new StateSet( name );
	if(! states_.add( name, set ) )
		return 0;

	return set;
}

StateSet* StateService::get_stateset( char* name ){
	return states_.get( name );
}
